import time import usb_hid import board from digitalio import DigitalInOut, Direction, Pull from adafruit_hid.keyboard import Keyboard from adafruit_hid.keycode import Keycode keyboard=Keyboard(usb_hid.devices) btn1_Pin = board.GP27 led1_pin = board.GP15 btn1 = DigitalInOut(btn1_Pin) btn1.direction = Direction.INPUT btn1.pull = Pull.UP led1 = DigitalInOut(led1_pin) led1.direction = Direction.OUTPUT while True: if btn1.value: led1.value = True keyboard.press(0x2C) else: led1.value = False keyboard.release(0x2C)